Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Xml
Imports System.Xml.Xsl
Partial Class HigherorderMenu
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            'litLeftMenu.Text = PopulateMenu()
            BindData()
        End If
    End Sub
    Private Sub BindData()
        Dim oXmlDocument As New XmlDocument()
        oXmlDocument.Load(Server.MapPath("~/XML/Menu.xml"))
        CallRecursive(oXmlDocument.ChildNodes(1))
    End Sub
    Private Sub CallRecursive(oXml as XmlElement)
        Dim i As Integer
        Dim j As Integer
        For i = 0 To oXml.ChildNodes.Count - 1
            If oXml.ChildNodes(i).Attributes IsNot Nothing And oXml.ChildNodes(i).Attributes.Count > 0 And oXml.ChildNodes(i).Attributes("id") IsNot Nothing And oXml.ChildNodes(i).Attributes("id").Value = Request("ParentID") Then
                litHeading.Text = oXml.ChildNodes(i).Attributes("text").Value
                If Request("SubMenu") IsNot Nothing Then
                    litBack.Text = String.Format("<a href=""javascript:void(0);"" onclick=""Back();""><img src=""{0}"" alt=""Back"" title=""Back"" border=""0""/></a>", ResolveUrl("images/Back.gif"))
                End If

                Dim MenuArray As New ArrayList()
                For j = 0 To oXml.ChildNodes(i).ChildNodes.Count - 1
                    Dim Temp As New MenuItem()
                    Temp.MenuID = oXml.ChildNodes(i).ChildNodes(j).Attributes("id").Value
                    Temp.Text = oXml.ChildNodes(i).ChildNodes(j).Attributes("text").Value
                    Temp.Href = oXml.ChildNodes(i).ChildNodes(j).Attributes("href").Value
                    Temp.Image = oXml.ChildNodes(i).ChildNodes(j).Attributes("image").Value
                    Temp.Target = oXml.ChildNodes(i).ChildNodes(j).Attributes("target").Value

                    MenuArray.Add(Temp)
                Next
                dlSubMenu.DataSource = MenuArray
                dlSubMenu.DataBind()
                If MenuArray.Count > 0 Then
                    litMessage.Text = ""
                Else
                    litMessage.Text = "No data found."
                End If
                Exit For
            Else
                CallRecursive(oXml.ChildNodes(i))
            End If
        Next
    End Sub
   
    Public Class MenuItem
        Private _MenuID As String
        Property MenuID() As String
            Get
                Return _MenuID
            End Get
            Set(ByVal value As String)
                _MenuID = value
            End Set
        End Property

        Private _Text As String
        Property Text() As String
            Get
                Return _Text
            End Get
            Set(ByVal value As String)
                _Text = value
            End Set
        End Property
        Private _Href As String
        Property Href() As String
            Get
                Return _Href
            End Get
            Set(ByVal value As String)
                _Href = value
            End Set
        End Property
        Private _Target As String
        Property Target() As String
            Get
                Return _Target
            End Get
            Set(ByVal value As String)
                _Target = value
            End Set
        End Property
        Private _Image As String
        Property Image() As String
            Get
                Return _Image
            End Get
            Set(ByVal value As String)
                _Image = value
            End Set
        End Property


    End Class
End Class


